<?php

class Question_Compensation extends Question {
	
	public function __construct() {
		$this->setScale(new ImportanceScale());
		$this->setText('Compensation:');
	}
	
	public function getResults(&$list) {
		$data = $list->getData('importance', 'compensation');
		$response = array();
		foreach ($this->scale->getScale() as $key => $text) {
			$response[$text] = $data[$key];
		}
		return $response;
	}

	public function getAverage(&$list) {
		$data = $list->getData('importance', 'compensation');
		$total = 0;
		$tCount = 0;
		foreach ($data as $value => $count) {
			if (is_numeric($value)) {
				$total += ($value * $count);
				$tCount += $count;
			}
		}
		return array('average' => $total / $tCount, 'base' => $tCount);
	}
	
}